home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / NumericSpinnerBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  5KB  |  152 lines

  1. package symantec.itools.awt.util.spinner;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  09/11/97    LAB    Removed redundant orientation property and connections.  Removed redundant
  8. //                    max and min properties and connections.
  9. //  08/19/98    LAB    Moved to GroupAWTAdditions folder.
  10.  
  11. /**
  12.  * BeanInfo for NumericSpinner.
  13.  *
  14.  */
  15. public class NumericSpinnerBeanInfo extends SimpleBeanInfo {
  16.  
  17.     /**
  18.      * Constructs a NumericSpinnerBeanInfo object.
  19.      */
  20.     public NumericSpinnerBeanInfo() {
  21.     }
  22.  
  23.     /**
  24.      * Gets a BeanInfo for the superclass of this bean.
  25.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  26.      */
  27.     public BeanInfo[] getAdditionalBeanInfo() {
  28.         try {
  29.             BeanInfo[] bi = new BeanInfo[1];
  30.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  31.             return bi;
  32.         }
  33.         catch (IntrospectionException e) { throw new Error(e.toString());}
  34.     }
  35.  
  36.     /**
  37.      * Gets the SymantecBeanDescriptor for this bean.
  38.      * @return an object of type SymantecBeanDescriptor
  39.      * @see symantec.itools.beans.SymantecBeanDescriptor
  40.      */
  41.     public BeanDescriptor getBeanDescriptor() {
  42.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  43.         String s=group.getString("GroupAWTAdditions"); 
  44.  
  45.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  46.         bd.setCanAddChild(false);
  47.         bd.setFolder(s);
  48.         bd.setToolbar(s);
  49.         bd.setWinHelp("0x123A8");
  50.  
  51.         bd.addAdditionalConnections(getAdditionalBeanInfo());
  52.  
  53.         return (BeanDescriptor) bd;
  54.     }
  55.  
  56.     /**
  57.      * Gets an image that may be used to visually represent this bean
  58.      * (in the toolbar, on a form, etc).
  59.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  60.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  61.      * @return an image for this bean, always color even if requested monochrome
  62.      * @see BeanInfo#ICON_MONO_16x16
  63.      * @see BeanInfo#ICON_COLOR_16x16
  64.      * @see BeanInfo#ICON_MONO_32x32
  65.      * @see BeanInfo#ICON_COLOR_32x32
  66.      */
  67.     public java.awt.Image getIcon(int iconKind) {
  68.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  69.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  70.             java.awt.Image img = loadImage("NumericSpinnerC16.gif");
  71.             return img;
  72.         }
  73.  
  74.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  75.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  76.             java.awt.Image img = loadImage("NumericSpinnerC32.gif");
  77.             return img;
  78.         }
  79.  
  80.         return null;
  81.     }
  82.  
  83.     /**
  84.      * Gets an array of descriptions of the methods used for "connections" by
  85.      * Visual CafΘ's Interaction Wizard.
  86.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  87.      * @return method descriptions for this bean
  88.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  89.      */
  90.     public MethodDescriptor[] getMethodDescriptors() {
  91.         Class[] args;
  92.         ConnectionDescriptor connection;
  93.         java.util.Vector connections;
  94.         java.util.Vector md = new java.util.Vector();
  95.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  96.  
  97.         try{
  98.             args = new Class[1];
  99.             args[0] = java.lang.Integer.TYPE ;
  100.             MethodDescriptor setIncrement = new MethodDescriptor(beanClass.getMethod("setIncrement", args));
  101.  
  102.             connections = new java.util.Vector();
  103.             connection = new ConnectionDescriptor("input", "int", "",
  104.                                     "%name%.setIncrement(%arg%);",
  105.                                     conn.getString("setIncrement"));
  106.             connections.addElement(connection);
  107.  
  108.             setIncrement.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  109.             md.addElement(setIncrement);
  110.         } catch (Exception e) { throw new Error("setIncrement:: " + e.toString()); }
  111.  
  112.         try{
  113.             args = null;
  114.             MethodDescriptor getIncrement = new MethodDescriptor(beanClass.getMethod("getIncrement", args));
  115.  
  116.             connections = new java.util.Vector();
  117.             connection = new ConnectionDescriptor("output", "int", "",
  118.                                     "%name%.getIncrement()",
  119.                                     conn.getString("getIncrement"));
  120.             connections.addElement(connection);
  121.  
  122.             getIncrement.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  123.             md.addElement(getIncrement);
  124.         } catch (Exception e) { throw new Error("getIncrement:: " + e.toString()); }
  125.  
  126.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  127.         md.copyInto(rv);
  128.  
  129.         return rv;
  130.     }
  131.  
  132.     /**
  133.      * Returns descriptions of this bean's properties.
  134.      */
  135.     public PropertyDescriptor[] getPropertyDescriptors() {
  136.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  137.  
  138.         try{
  139.         PropertyDescriptor increment = new PropertyDescriptor("increment", beanClass);
  140.         increment.setBound(true);
  141.         increment.setConstrained(true);
  142.         increment.setDisplayName(prop.getString("increment"));
  143.  
  144.         PropertyDescriptor[] rv = {
  145.             increment};
  146.         return rv;
  147.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  148.     }
  149.  
  150.     private final static Class beanClass = NumericSpinner.class;
  151.  
  152.     }    //  end of class NumericSpinnerBeanInfo